Kresleni kolem okna
Otázka od: Dalibor Faltynel
8. 11. 2004 8:31
Ahoj pratele,
zcasti jsem vycetl, zcasti upravil kod pro vykreslovani ramecku kolem oken,
kdyz nad nimi zastavim mys a pockam na timer. Potud to funguje dobre. Ale
jak mam zase ty ramecky mazat a obnovit puvodni vzhled? Mel bych nejak
prekreslit plochu, ale nevim jak. Prosim, pomozte mi nekdo, zkousel jsem
UpdateWindow, a InvalidateRect na ruznych mistech, ale to asi neni ono. Toto
je kod kresleni ramecku.
procedure TForm1.Timer1Timer(Sender: TObject);
var
dc: hDc;
Pen: hPen;
OldPen: hPen;
OldBrush: hBrush;
RR: TRect;
PRR: Pointer;
begin
dc:=GetWindowDC(GetWindowUnderMouse);
Pen:=CreatePen(PS_SOLID, 5, RGB(0,255,0));
OldPen:=SelectObject(dc, Pen);
OldBrush:=SelectObject(dc, GetStockObject(NULL_BRUSH));
GetWindowRect(WindowFromDC(dc), RR);
Rectangle(dc,0,0,RR.Right - RR.left,RR.Bottom - RR.Top);
SelectObject(dc, OldBrush);
SelectObject(dc, OldPen);
DeleteObject(Pen);
InvalidateRect(dc, PRR, true);
updateWindow(WindowFromDC(dc));
ReleaseDC(Handle, Canvas.Handle);
end;
Odpovedá: Ing. Jan Dvorak
8. 11. 2004 15:51
Zkus Repaint.
Jan Dvorak
> -----Original Message-----
> From: delphi-l-owner@clexpert.cz
> [mailto:delphi-l-owner@clexpert.cz] On Behalf Of Dalibor Faltynel
> Sent: Monday, November 08, 2004 8:27 AM
> To: delphi-l@clexpert.cz
> Subject: Kresleni kolem okna
>
> Ahoj pratele,
> zcasti jsem vycetl, zcasti upravil kod pro vykreslovani
> ramecku kolem oken,
> kdyz nad nimi zastavim mys a pockam na timer. Potud to
> funguje dobre. Ale
> jak mam zase ty ramecky mazat a obnovit puvodni vzhled? Mel bych nejak
> prekreslit plochu, ale nevim jak. Prosim, pomozte mi nekdo,
> zkousel jsem
> UpdateWindow, a InvalidateRect na ruznych mistech, ale to asi
> neni ono. Toto
> je kod kresleni ramecku.
>
> procedure TForm1.Timer1Timer(Sender: TObject);
> var
> dc: hDc;
> Pen: hPen;
> OldPen: hPen;
> OldBrush: hBrush;
> RR: TRect;
> PRR: Pointer;
> begin
> dc:=GetWindowDC(GetWindowUnderMouse);
> Pen:=CreatePen(PS_SOLID, 5, RGB(0,255,0));
> OldPen:=SelectObject(dc, Pen);
> OldBrush:=SelectObject(dc, GetStockObject(NULL_BRUSH));
> GetWindowRect(WindowFromDC(dc), RR);
> Rectangle(dc,0,0,RR.Right - RR.left,RR.Bottom - RR.Top);
> SelectObject(dc, OldBrush);
> SelectObject(dc, OldPen);
> DeleteObject(Pen);
> InvalidateRect(dc, PRR, true);
> updateWindow(WindowFromDC(dc));
> ReleaseDC(Handle, Canvas.Handle);
> end;
>
>
>
Odpovedá: Dalibor Faltynel
9. 11. 2004 9:43
Myslim, ze Repaint asi nemuzu pouzit na cizi okno. V API helpu jsem si
nasel, ze podnet k prekresleni okna, nebo vsechna okna by mela API fce
InvalidateRect s ruznymi parametry viz dale. Zkusil jsem to takto
InvalidateRect(null, nil, true); a dostal chybu type conversion. V cem je
chyba?
Diky - Dalibor.
Vypis Helpu:
The InvalidateRect function adds a rectangle to the specified
window's
update region. The update region represents the portion of the window's
client area that must be redrawn.
BOOL InvalidateRect(
HWND hWnd, // handle of window with changed update region
CONST RECT *lpRect, // address of rectangle coordinates
BOOL bErase // erase-background flag
);
Parameters
hWnd
Identifies the window whose update region has changed. If this parameter is
NULL, Windows invalidates and redraws all windows, and sends the
WM_ERASEBKGND and WM_NCPAINT messages to the window procedure before the
function returns.
lpRect
Points to a RECT structure that contains the client coordinates of the
rectangle to be added to the update region. If this parameter is NULL, the
entire client area is added to the update region.
bErase
Specifies whether the background within the update region is to be erased
when the update region is processed. If this parameter is TRUE, the
background is erased when the BeginPaint function is called. If this
parameter is FALSE, the background remains unchanged.
> Zkus Repaint.
>
> > UpdateWindow, a InvalidateRect na ruznych mistech, ale to asi
> > neni ono. Toto